﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Takkou.Language
{
    // generic string
    public interface String
    {
        string get();
    }

    // fixed string value
    public class ValString : String
    {
        private string value;

        public ValString(string v)
        {
            value = v;
        }

        public string get()
        {
            return value;
        }
    }

    // string got from a property of an object (ex: robot's name)
    public class RefString : String
    {
        private Func<string> property;

        public RefString(Func<string> prop)
        {
            property = prop;
        }

        public string get()
        {
            return property();
        }
    }

    // string as a result of a binary expression or operation
    public class BinaryExpString : String
    {
        public enum ExpType
        {
            ADD,   // +
            // others here
        }

        public String Str1 { get; private set; }
        public String Str2 { get; private set; }
        public ExpType Type { get; private set; }

        public BinaryExpString(ExpType type, String s1, String s2)
        {
            Str1 = s1;
            Str2 = s2;
            Type = type;
        }

        public string get()
        {
            switch (Type)
            {
                case ExpType.ADD:
                    return Str1.get() + Str2.get();
            }
            // TODO throw an exception
            return "";
        }
    }
}
